home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_gettext.idb / usr / freeware / include / libintl.h.z / libintl.h
Encoding:
C/C++ Source or Header  |  1999-04-16  |  3.4 KB  |  109 lines

  1. /* libintl.h -- Message catalogs for internationalization.
  2. Copyright (C) 1995 Free Software Foundation, Inc.
  3.  
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8.  
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. GNU General Public License for more details.
  13.  
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  17.  
  18. #ifndef _LIBINTL_H
  19. #define _LIBINTL_H    1
  20.  
  21. #ifdef HAVE_LOCALE_H
  22. # include <locale.h>
  23. #endif
  24.  
  25. /* We define an additional symbol to signal that we use the GNU
  26.    implementation of gettext.  */
  27. #define __USE_GNU_GETTEXT 1
  28.  
  29. #ifndef __P
  30. # if __STDC__
  31. #  define __P(args) args
  32. # else
  33. #  define __P(args) ()
  34. # endif
  35. #endif
  36.  
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40.  
  41. /* Look up MSGID in the current default message catalog for the current
  42.    LC_MESSAGES locale.  If not found, returns MSGID itself (the default
  43.    text).  */
  44. extern char *gettext __P ((const char *__msgid));
  45.  
  46. /* Look up MSGID in the DOMAINNAME message catalog for the current
  47.    LC_MESSAGES locale.  */
  48. extern char *dgettext __P ((const char *__domainname, const char *__msgid));
  49.  
  50. /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
  51.    locale.  */
  52. extern char *dcgettext __P ((const char *__domainname, const char *__msgid,
  53.                  int __category));
  54.  
  55.  
  56. /* Set the current default message catalog to DOMAINNAME.
  57.    If DOMAINNAME is null, return the current default.
  58.    If DOMAINNAME is "", reset to the default of "messages".  */
  59. extern char *textdomain __P ((const char *__domainname));
  60.  
  61. /* Specify that the DOMAINNAME message catalog will be found
  62.    in DIRNAME rather than in the system locale data base.  */
  63. extern char *bindtextdomain __P ((const char *__domainname,
  64.                   const char *__dirname));
  65.  
  66.  
  67. /* Optimized version of the functions above.  */
  68. #if defined __OPTIMIZED
  69. /* These must be a macro.  Inlined functions are useless because the
  70.    `__builtin_constant_p' predicate in dcgettext would always return
  71.    false.  */
  72.  
  73. # define gettext(msgid) dgettext ((char *) 0, msgid)
  74.  
  75. # define dgettext(domainname, msgid)                          \
  76.   dcgettext (domainname, msgid, LC_MESSAGES)
  77.  
  78. # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
  79. #  define dcgettext(domainname, msgid, category)                  \
  80.   (__extension__                                  \
  81.    ({                                          \
  82.      char *result;                                  \
  83.      if (__builtin_constant_p (msgid))                          \
  84.        {                                      \
  85.      extern int _nl_msg_cat_cntr;                          \
  86.      static char *__translation__;                          \
  87.      static int __catalog_counter__;                      \
  88.      if (! __translation__ || __catalog_counter__ != _nl_msg_cat_cntr)    \
  89.        {                                      \
  90.          __translation__ =                              \
  91.            (dcgettext) ((domainname), (msgid), (category));              \
  92.          __catalog_counter__ = _nl_msg_cat_cntr;                  \
  93.        }                                      \
  94.      result = __translation__;                          \
  95.        }                                      \
  96.      else                                      \
  97.        result = (dcgettext) ((domainname), (msgid), (category));          \
  98.      result;                                      \
  99.     }))
  100. # endif
  101. #endif /* Optimizing. */
  102.  
  103.  
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107.  
  108. #endif /* libintl.h */
  109.